package com.xl.cloud.apis;

import com.xl.cloud.entities.PayDTO;
import com.xl.cloud.resp.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Author XiangLiang
 * @Since 2024/9/13 8:51
 * @Description: PayFeignApi类
 */
// @Component
@FeignClient(value = "cloud-payment-service")
public interface PayFeignApi {
    /**
     * 新增一条支付相关流水记录
     */
    @PostMapping(value = "/pay/add")
    public ResultData addPay(@RequestBody PayDTO pay);

    @DeleteMapping(value = "/pay/del/{id}")
    public ResultData deletePay(@PathVariable("id") Integer id);

    @PutMapping(value = "/pay/update")
    public ResultData updatePay(@RequestBody PayDTO payDTO);

    /**
     * 按照主键记录查询支付流水信息
     */
    @GetMapping(value = "/pay/get/{id}")
    public ResultData getById(@PathVariable("id") Integer id);

    /**
     * openfeign天然支持负载均衡演示
     * 查询所有支付流水
     */
    @GetMapping(value = "/pay/getAll")
    public ResultData getAll();

    @GetMapping(value = "/pay/get/info")
    public String mylb();

    /**
     * Resilience4j CircuitBreaker 的例子
     */
    @GetMapping(value = "/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id);

    /**
     * Resilience4j Bulkhead 的例子
     */
    @GetMapping(value = "/pay/bulkhead/{id}")
    public String myBulkhead(@PathVariable("id") Integer id);

    /**
     * Resilience4j Ratelimit 的例子
     */
    @GetMapping(value = "/pay/ratelimit/{id}")
    public String myRateLimit(@PathVariable("id") Integer id);

    /**
     * Micrometer(Sleuth)进行链路监控的例子
     */
    @GetMapping(value = "/pay/micrometer/{id}")
    public String myMicrometer(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例01
     */
    @GetMapping(value = "/pay/gateway/get/{id}")
    public ResultData getByIdGateway(@PathVariable("id") Integer id);

    /**
     * GateWay进行网关测试案例02
     */
    @GetMapping(value = "/pay/gateway/info")
    public ResultData<String> getGatewayInfo();
}
